
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[WordBookmarkSelectAll]
    @WordTemplateId INT ,
    @IsOnlyVisible BIT ,
    @IsWithGrouped BIT
AS 
    BEGIN
        SELECT  Id ,
                WordTemplateId ,
                Name ,
                Description ,
                DateCreated ,
                IsTextBookmark ,
                BookmarkGroupId ,
                Visible ,
                Deleted
        FROM    WordBookmark
        WHERE   WordTemplateId = @WordTemplateId
                AND ( ( @IsWithGrouped = 0
                        AND BookmarkGroupId IS NULL
                      )
                      OR ( @IsWithGrouped = 1 )
                    )
                AND ( ( @IsOnlyVisible = 0
                        AND Deleted = 0
                      )
                      OR ( @IsOnlyVisible = 1
                           AND Visible = 1
                           AND Deleted = 0
                         )
                    )
        ORDER BY Name
    END
GO
